//
//  RootViewController.m
//  课余时间
//
//  Created by zgr on 16/4/6.
//  Copyright © 2016年 张大少. All rights reserved.
//

#import "RootViewController.h"
#import "UIView+SDAutoLayout.h"
#import "RightViewController.h"
@interface RootViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic ,strong)UITableView *tabelView;
@property (nonatomic ,strong)UIImageView *headImage;
@property (nonatomic, strong)NSArray *modelArray;
@property (nonatomic,strong)RightViewController *right;
@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _headImage = [[UIImageView alloc]initWithFrame:CGRectMake(20, 30, 60, 60)];
    _headImage.backgroundColor = [UIColor cyanColor];
    _headImage.layer.cornerRadius = 30;
    [self.view addSubview:_headImage];
    _tabelView = [[UITableView alloc]initWithFrame:CGRectMake(0, 160, 200, 500) style:UITableViewStylePlain];
    
    [_tabelView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    _tabelView.scrollEnabled = NO;
    _tabelView.dataSource = self;
    _tabelView.delegate = self;
    
    [self.view addSubview:_tabelView];
    
   _modelArray = @[@"游戏资讯",@"新闻要事",@"电台",@"视频",@"读物",@"音乐"];
    
    _right = [[RightViewController alloc]init];
    
    [self.view addSubview:_right.view];
    
    // Do any additional setup after loading the view from its nib.
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _modelArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.textLabel.text = _modelArray[indexPath.row];
    return cell;
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [_right changViewWithIndex:indexPath.item];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
